package com.liucxu.jiandanl.Business;

import com.google.gson.Gson;
import com.liucxu.jiandanl.Consts.Urls;
import com.liucxu.jiandanl.Entity.PicComments;
import com.liucxu.jiandanl.Http.RequestManager;
import com.liucxu.jiandanl.Interface.RequestCallbackInterface;

import java.util.List;

import de.greenrobot.event.EventBus;


/**
 * 获取无聊图的Event
 * Created by liuchenxu on 2016/8/4.
 */
public class PicturesEvent extends BaseEvent {

    private String status;

    private int current_page;

    private int total_comments;

    private int page_count;

    private int count;

    private List<PicComments> comments ;

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public int getCurrent_page() {
        return current_page;
    }

    public void setCurrent_page(int current_page) {
        this.current_page = current_page;
    }

    public int getTotal_comments() {
        return total_comments;
    }

    public void setTotal_comments(int total_comments) {
        this.total_comments = total_comments;
    }

    public int getPage_count() {
        return page_count;
    }

    public void setPage_count(int page_count) {
        this.page_count = page_count;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public List<PicComments> getComments() {
        return comments;
    }

    public void setComments(List<PicComments> comments) {
        this.comments = comments;
    }

    /**
     * 获取无聊图的方法
     * @param pageIndex
     */
    public static void GetPicturesByPage(int pageIndex){

        RequestManager.GET(Urls.BORING_PICS_URL + pageIndex, new RequestCallbackInterface() {
            @Override
            public void onSuccess(String response) {
                PicturesEvent event=(new Gson()).fromJson(response,PicturesEvent.class);
                event.setResultCode(1);
                EventBus.getDefault().post(event);
            }

            @Override
            public void onFail() {
                PicturesEvent event=new PicturesEvent();
                event.setResultCode(0);
                EventBus.getDefault().post(event);
            }
        });
    }
}
